<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <title>评论管理-{$title}-见微-全媒体记者发稿助手</title>
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <link href="__PUBLIC__/css/base.css" rel="stylesheet">
    <link rel="stylesheet" href="http://cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css">
    <script src="http://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <style>
        html,body{background: #fff;}
        .search{padding-top:20px;padding-left: 15px}
        .comment{padding: 15px 20px}
        .comment td,.comment th{text-align: center;font-size: 14px}
        .flickr{text-align: center}
        .flickr a,.flickr span{display: inline-block;border:1px solid #f0f0f0;background: #fff;color:#000;border-radius:5px;font-size: 16px;padding:0 8px;min-width:40px;height: 40px;line-height: 40px;margin-right: 3px;}
        .flickr span{background: #ff5356;color:#fff;}
        .deleted_comment{color: #aaa}
        #flushComment{position: absolute;top: 20px;right: 51px;}
        .comment_switch { position: absolute; left: 0px; height: 30px; width: 300px; top:20px; }
        .comment_switch label {display: inline-block;}
    </style>


    <link href="__PUBLIC__/css/bootstrap-switch.min.css" rel="stylesheet">
    <script src="__PUBLIC__/js/bootstrap-switch.min.js"></script>
</head>
<body>
<div class="comment_switch">
审核开关：
<?php if($live_info['is_verify'] == 0) { ?>
<input type="checkbox" name="is_verify" data-on-color="danger" data-off-text="先发后审" data-on-text="先审后发" data-size="small">
<?php } else { ?>
<input type="checkbox" name="is_verify"  data-on-color="danger" checked data-off-text="先发后审" data-on-text="先审后发" data-size="small">
<?php } ?>
</div>
<button type="button" class="btn btn-sm btn-info" id="flushComment">刷新评论</button>

<div id="commentHolder">
    <div class="search">
        <form action="{:U('index')}" method="get"  class="form-inline text-center">
            <div class="form-group">
                <label>昵称：</label><input type="text" name="nickname" value="{$Think.get.nickname}" class="form-control" />
            </div>
            <div class="form-group">
                <label>内容：</label><input type="text" name="content" value="{$Think.get.content}"  class="form-control" />
            </div>
            <div class="form-group">
                <button type="submit"  class="btn btn-warning btn-sm" />搜索</button>
            </div>

            <input type="hidden" name="group_id" value="{$Think.get.group_id}"  class="form-control" />
        </form>
    </div>

    <?php if($commentList) { ?>
    <div class="comment">
        <table class="table table-striped table-hover">
            <tr>
                <th width="10%">用户名</th>
                <th width="45%"  style="text-align: left;">评论内容</th>
                <th width="15%">IP</th>
                <th width="15%">时间</th>
                <th width="15%">操作</th>
            </tr>
            <volist name='commentList' id="vo">
                <tr <?php if($vo['is_delete']==1){ ?>class="deleted_comment"<?php }?>>
                <td>{$vo['username']}</td>
                <td style="text-align: left;">
                    <?php if($vo['is_delete']==1){ ?>
                    [已删除]
                    <?php }?>
                    {$vo['content']}
                </td>
                <td>{$vo['ip']}</td>
                <td>{$vo['time']|date="Y/m/d H:i",###}</td>
                <td>
                    <?php if($vo['is_delete']==0){ ?>
                    <?php if($vo['is_verify'] == 1) { ?>
                    <a onclick="return confirm('是否确定打回此条评论？')" href="{:U('verifyCommentById')}?id={$vo['id']}&status=0" class="title">打回</a>
                    <?php } else { ?>
                    <a onclick="return confirm('是否确定通过此条评论？')"  href="{:U('verifyCommentById')}?id={$vo['id']}&status=1" class="title">通过</a>
                    <?php } ?>
                    |
                    <a onclick="return confirm('是否确定删除此条评论？')"  href="{:U('delCommentById')}?id={$vo['id']}" class="title">删除</a>
                    <?php } ?>
                </td>
                </tr>
            </volist>
        </table>
    </div>
    <?php } else { ?>
    暂无评论
    <?php } ?>
    <div class="flickr">{$page}</div>
</div>

<script>
    $("#flushComment").click(function(){
        location.reload();
    })


    /*评论面板开关*/
    $("[name='is_verify']").bootstrapSwitch();
    $("[name='is_verify']").on('switchChange.bootstrapSwitch', function(event, state) {
        event.preventDefault();

        var _this = this;
        status=state===false?0:1;
        $.post('{:U("Home/Live/setLiveVerify")}?group_id={$_GET["group_id"]}', {'status': status}, function (data) {
            if(data['status'] != 2) {
                if(data.status == 1) {
                    $(_this).bootstrapSwitch('setState', true,true);
                } else {
                    $(_this).bootstrapSwitch('setState', false, false);
                }
            } else {
                $(_this).bootstrapSwitch('setState',state,state);
                $.alert(data.msg);
            }
        })
    });
</script>
</body>
</html>